<template>
  <ul class="steps">
      <li
        v-for="(item, index) in dates"
        :key="index"
        :class="{ 'active' : activeDates.includes(item) }">
        {{ item }}
      </li>
  </ul>
</template>
<script>
export default {
  props: {
    curr: {
      type: Array
    },
    dates: {
      type: Array
    },
    range: {
      type: Array
    }
  },
  data() {
    return {
      activeDates: []
    }
  },
  watch: {
    curr() {
      this.calculateActive()
    }
  },
  methods: {
    calculateActive() {
      this.activeDate = []
      this.range.forEach((item, index) => {
        if(this.curr.includes(item)) {
          this.activeDates.push(this.dates[index])
        }
      })
      console.log(this.activeDates)
    }
  }
}
</script>

<style scoped>
.steps {
  height: 55px;
  background: #fff;
  padding: 10px 0;
  position: relative;
  margin:20px 10px;
  counter-reset: step; /*创建步骤数字计数器*/
  display: flex;
  justify-content: space-around;
  align-items: center;
}
/*步骤描述*/
.steps li {
  list-style-type: none;
  font-size: 12px;
  text-align: center;
  position: relative;
  flex-wrap: nowrap;
}

/*步骤数字*/
.steps li:before {
  display: block;
  content: counter(step); /*设定计数器内容*/
  counter-increment: step; /*计数器值递增*/
  width: 32px;
  height: 32px;
  background-color: #ddd;
  line-height: 32px;
  border-radius: 32px;
  font-size: 16px;
  color: #fff;
  text-align: center;
  font-weight: 700;
  margin: 0 auto 8px auto;
}

/*连接线*/
.steps li:not(:last-child)::after {
  content: "";
  width: 100%;
  height: 2px;
  margin: 0 32px;
  background-color: #ddd;
  position: absolute;
  left: 0;
  top: 15px;
}

/*将当前/完成步骤之前的数字及连接线变蓝*/
.steps li.active:before,
.steps li.active:after {
  background-color: #1989fa;
}

</style>